<?php
$usr= $_POST['email'];
$pswd = $_POST['pswd'];

include ("DBKonexioa.php");


$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');


$konexioa = new DBKonexioa();
if($konexioa->konektatu()!=true){
	die ("Errorea DBra konektatzen saiatzean.");
} else {
	$sql = "SELECT * FROM usuario WHERE email='$usr' and pswd=SHA('$pswd')";
	$emaitzak = mysql_query($sql);
	if (mysql_num_rows($emaitzak) == 1) {
		$row=mysql_fetch_assoc($emaitzak);	
		session_start();		
		$_SESSION['idUsr']=$row['id_usuario'];
		$extra = 'home.php';
		header("Location: http://$host$uri/$extra");
		exit;
	}else
		$extra = "../index.php?errorea=1";
		header("Location: http://$host$uri/$extra");
		exit;
}
$konexioa->konexioaItxi();
?>